<?php
class PageController extends Pidguin_Controller_Public_Action
{
	public function indexAction()
	{
		$this->_helper->viewRenderer->setNoRender();
	}
	
	public function getAction()
	{
		if (!$this->_getParam('page_name')) {
			throw new Zend_Controller_Action_Exception('Page not available');
		}
		
		$select = Model_Page::getInstance()->select();
		$select->where(
				Model_Page::getInstance()
					->getAdapter()
					->quoteInto('name = ?', $this->_getParam('page_name')
				));
		$row = Model_Page::getInstance()->fetchRow($select);
		
		if (!$row) {
			throw new Zend_Controller_Action_Exception('Page not found');
		}
		
		$this->view->headTitle($row->title);
		
		$this->view->page = $row;
		
		$date = new Zend_Date($row->created, false, $this->_app->getLocale());
		
		$this->view->date = $date->toString('dd MMMM');
		$this->view->time = $date->toString('HH:mm');
		
		$this->view->author = $row->findParentRow('Model_User');
	}
}